package com.hxd.otc.module.convenience.presenter;

import android.support.annotation.NonNull;

import com.hxd.otc.base.BaseBean;
import com.hxd.otc.module.convenience.bean.ConvenienceOrderBean;
import com.hxd.otc.module.convenience.contract.ConvenienceOrderContract;
import com.hxd.otc.module.convenience.model.ConvenienceModel;
import com.hxd.otc.module.my.bean.BaseListBean;
import com.hxd.otc.mvp.base.BasePresenter;
import com.hxd.otc.net.BaseObserver;

import java.util.List;

/**
 * 作  者 :  zjl
 * 时  间 :  2018/6/4 17:02
 * 描  述 :  ${所有订单页面P}
 */
public class ConvenienceOrderPresenter extends BasePresenter<ConvenienceOrderContract.View> implements ConvenienceOrderContract.Presenter {

    ConvenienceModel model;

    public ConvenienceOrderPresenter(ConvenienceOrderContract.View view) {
        super(view);
        model = ConvenienceModel.getInstance();
    }


    @Override
    public void doShowNoMore() {

        mView.onShowNoMore();
    }

    @Override
    public void doSetAdapter(List<ConvenienceOrderBean> data) {

        mView.onSetAdapter(data);
    }

    @Override
    public void onLoadOrderList(int showCount, int currentPage) {
        model.getOrderList(showCount, currentPage, new BaseObserver<BaseListBean<ConvenienceOrderBean>>() {
            @Override
            public void onNext(@NonNull String msg, @NonNull BaseListBean<ConvenienceOrderBean> listBean) {

                doShowNoMore();
                doSetAdapter(listBean.getList());
            }

            @Override
            public void onError(int errType, @NonNull String errMessage) {
                mView.showToast(errMessage);
                doShowNoMore();
            }
        }, mView.<BaseBean<BaseListBean<ConvenienceOrderBean>>>bindAutoDispose());

    }
}
